Repository navigation
surface_input: scroll, off-surface ups, click count, and hover edges - #6
Conversation
SurfaceEvent had no Scroll variant, so a producer binding a wheel had to go around the gateway and the enum docs linked to an item that did not exist. Register on_scroll_wheel alongside the pointer handlers, carry the pointer position so a zoom can stay anchored, and map GPUI ScrollDelta to SurfaceScroll: a pixel delta is converted to the physical pixels the rest of the gateway uses, while a line delta passes through in lines.
on_mouse_up_out was gated on the engine drag, but the engine founds a drag only for a left press past the 2px threshold. A right or middle press, or a left press released after a sub-threshold move, therefore never produced a PointerUp when released outside the surface, leaving the producer stuck in its pressed state. Record which surface owns the current press on the App, clear it on the up, and report an off-surface up when either the drag or the press is ours.
PointerDown dropped MouseDownEvent::click_count, so a producer could not tell a double-click from two clicks without rebuilding the platform time/distance heuristic. Copy it to both PointerDown and PointerUp, matching the engine events they adapt.
The gateway reported moves, downs and ups, so a producer that highlights a gizmo or a navigation-cube face had no way to clear that state once the pointer left; a stationary leave can produce no further move at all. Subscribe on_hover and forward both edges as PointerEnter/PointerLeave, with modifiers but no position. The transition mirrors the engine hover state, including its suppression during a press or an active drag.
|
Reviewed against The implementation is the right shape and matches what we use — press ownership, scroll conversion and the click count are all in the places I'd expect. One real breakage, then docs, semantics and test nits. Blocking: the example no longer compiles
match input.event {
SurfaceEvent::PointerDown { position, .. } => { … }
SurfaceEvent::PointerMove { position, .. } if grab.get() => { … }
SurfaceEvent::PointerMove { .. } => {}
SurfaceEvent::PointerUp { .. } => { … }
}Adding The CI is green because no job enables the Suggested fix, which also fixes the now-false comments:
And add Documentation
API / semantics
Tests
What looks good
Downstream noteOur vendored copy already has the new variants, so its |
The example now handles SurfaceEvent::Scroll through the gateway and has arms for the hover edges, so its match is exhaustive again; the package job checks examples with the example feature. Restore the scroll sign convention and fix the delta and PointerLeave wording; document that the gateway claims the on_hover slot. Press ownership now records one entry per window, surface and button, so a left release no longer forgets a held middle press and two windows do not share it. Add tests for a line scroll, PointerUp click_count, exact off-surface up counts, and a chord.
|
Thanks — all of it is addressed in Blocking: the example — Docs — restored the sign sentence on API / semantics — the module docs now say the gateway claims Tests — added the CI is green on the new head. |
Fix the four open input-gateway issues.
SurfaceEventhas noScroll, though the enum docs link to it #2:SurfaceEvent::Scroll/SurfaceScroll; precise deltas are converted to physical pixels, line deltas pass through.App, so right/middle presses and sub-threshold left presses reportPointerUpoutside the surface.MouseDownEvent::click_count, so a producer cannot see a double-click #4:click_countonPointerDownandPointerUp.PointerEnter/PointerLeavefrom the engine hover edges.Validation:
cargo test -p gpui_interop --features input-test --test surface_input- 16 passed.